const app = getApp();
Component({
  options: {
    addGlobalClass: true,
  },
  // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
  attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
  ready: function() {
    this.getActivitys();
  },
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    list: []
  },
  methods: {
    toChild(e) {
      wx.navigateTo({
        url: '/pages/activitys/detail/detail?id=' + e.currentTarget.dataset.id
      })
    },

    /**
     * 获取活动列表
     */
    getActivitys() {
      let _that = this;
      let _url = app.globalData.apiServerUrl + '/list';
      wx.request({
        url: _url,
        success(res) {
          let _d = res.data.data;
          _that.setData({
            list:_d
          });
        }
      })
    }
  }
});